// 左边的边栏
var lis = document.querySelectorAll("ul.tab-title>li");
	// 给li每一个绑定点击事件
for(var i = 0,len = lis.length; i < len; i++) {
	lis[i].onclick = function() {
		if(this.classList.contains("active")) return;
		var activeLi = document.querySelector(".active");
		if(activeLi) activeLi.classList.remove("active");
		this.classList.add("active");
	}
}
var ob = new IntersectionObserver(
	function(entry) {
		if (entry[0].isIntersecting) {
			var activeLi = document.querySelector(".tab-title>li.active");
			if (activeLi) activeLi.classList.remove("active");
			lis[entry[0].target.index].classList.add("active");
		}
	}, {
	root: null,
	rootMargin: "-45% 0px -50% 0px",
	threshold: [0]
	}
);
var parts = document.querySelectorAll(".part");
for(var i = 0,len = parts.length; i < len; i++) {
	parts[i].index = i;
	ob.observe(parts[i]);
}
// 网页的动态渲染
var commodities = [
	{name: "TCL&nbsp;98Q10G&nbsp;Mini&nbsp;LED巨幕电视", price: 22999.00, pasrent: "images/sp01.png",a: "page/detail"},
	{name: "TCL&nbsp;8517G&nbsp;高画质&nbsp;144HZ真高刷电视II", price:8999.00, pasrent: "images/sp02.png",a: ""},
	{name: "TCL&nbsp;85V6E&nbsp;Pro&nbsp;高色域巨幕影院", price: 5499.00, pasrent: "images/sp28.png",a: ""},
	{name: "TCL&nbsp;75V8E&nbsp;120HZ投屏电视", price: 3799.00, pasrent: "images/sp04.png",a: ""},
	{name: "TCL&nbsp;65T8E&nbsp;Max&nbsp;原色量子电视", price: 3599.00, pasrent: "images/sp26.png",a: ""},
	{name: "TCL&nbsp;55V8E&nbsp;Pro&nbsp;120HZ高色域电视", price: 2199.00, pasrent: "images/sp29.png",a: ""},
	
];
var htmlStr = "";
commodities.forEach(function(item) {
	htmlStr += `
		<div> 
			<a href ="${item.a}">
				<img src="${item.pasrent}" alt="">
				<h5>${item.name}</h5>
				<span>${item.price}.00元</span>
			</a>
		</div>
	`	
})
